﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using CPETwit.WPFClient.Business.TwitterServiceReference;
using System.Windows;
using CPETwit.WPFClient.Common;

namespace CPETwit.WPFClient.Converter
{
    public class RetweetVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is Tweet)
            {
                Tweet tweet = value as Tweet;

                if (CommonData.LOGGED_USER == null)
                    return Visibility.Visible;

                return CommonData.CanReTweet(CommonData.LOGGED_USER, tweet) ||
                       CommonData.CanUndoReTweet(CommonData.LOGGED_USER, tweet) ?
                       Visibility.Visible : Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
